﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using TomShane.Neoforce.Controls;

namespace SpaceInvade
{
    public class Star
    {
        static Manager Manager;
        //sprite position
        public Vector2 position = new Vector2(0,0);
        int velocity;
        //sprite image
        private Texture2D sprite;
        // Vector for screen borders
        Vector2 ScreenEdge;
        public Star(Manager _Manager)
        {
            Manager = _Manager;
            Random randomGen = new Random();
            velocity = randomGen.Next(1, 5);
            ScreenEdge.X = Manager.GraphicsDevice.Viewport.Bounds.Width;
            ScreenEdge.Y = Manager.GraphicsDevice.Viewport.Bounds.Height;
            sprite = Manager.Content.Load<Texture2D>(@"Textures\starfield");

                //First creation, create at random x AND y position
                int x = randomGen.Next(0, (int)ScreenEdge.X);
                int y = randomGen.Next(0, (int)ScreenEdge.Y);
                position = new Vector2(x, y);
        }

        public void Draw(SpriteBatch starSpriteBatch)
        {
            //sprite = content.Load<Texture2D>(@"Textures\starfield");
            starSpriteBatch.Draw(sprite, position, Color.SlateGray);
        }

        public bool Update()
        {
            //After init, create ONLY at random x position
            //constructor
            position = new Vector2(position.X,position.Y + velocity);
            //Check if outside room (screen), if outside room then delete
            if ((position.X < 0 || position.X > ScreenEdge.X) &&
                (position.Y < 0 || position.Y > ScreenEdge.Y))
                return true;
            else
                return false;
        }
    }
}
